<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.ss_entry_url.php
 * Type:     function
 * Name:     ss_entry_url
 * Purpose:  Returns url from entry object
 * -------------------------------------------------------------
 */
 
function smarty_function_ss_archive_url($params, &$smarty){
	/*if(!array_key_exists('node',$params)) {
		$smarty->trigger_error("Entry node not set");
		return;
	}*/
	//ss_error::log($smarty->get_template_vars );
	//$date=explode('-',(is_null($params['node']['date_pub'])?$params['node']['created_at']:$params['node']['date_pub']));
	if($params['absolute']){
		$settings=$smarty->get_template_vars('settings');
		$result=$settings['server']['appath']['entry'].$params['year'];
		if(array_key_exists('month',$params)) $result.='/'.str_pad($params['month'],2,'0',STR_PAD_LEFT);
		//return ($settings['server']['appath']['entry'].$date[0].'/'.$date[1].'/'.$params['node']['slug']);
	} else {
		$result=$params['year'];
		if(array_key_exists('month',$params)) $result.='/'.str_pad($params['month'],2,'0',STR_PAD_LEFT);
		$result=$smarty->get_template_vars('context')->url($result);
	}
	return $result;
}
?>